package site.teamo.biu.net.common.web.configuration;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: 爱做梦的锤子
 * @date: 2023/4/3 21:26
 */
@Configuration
public class UiConfiguration implements WebMvcConfigurer {

    @Value("${biu-net.ui.resource-locations}")
    private String uiResourceLocations;


    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //配置ui的页面解析
        registry.addResourceHandler("/ui/**")
                .addResourceLocations(uiResourceLocations)
                .resourceChain(false);
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/")
                .setViewName("redirect:/ui/index.html");
        registry.addViewController("/ui")
                .setViewName("redirect:/ui/index.html");
    }
}
